﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using DFT.DB;
using DFT.Infos;

namespace DFT
{
    public partial class Relations : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Request.QueryString["ida"]) || !String.IsNullOrEmpty(Request.QueryString["ids"]))
            {
                DataTable profilesTable = new DataTable("profiles");
                Int64 treeId = !String.IsNullOrEmpty(Request.QueryString["ida"]) ? Int64.Parse(Request.QueryString["ida"]) : Int64.Parse(Request.QueryString["ids"]);
                treeName.Text = !String.IsNullOrEmpty(Request.QueryString["name"]) ? Request.QueryString["name"] : "";
                if (DBManager.GetAllProfilesUser(treeId, ref profilesTable))
                {
                    familyTreeView.Nodes.Clear();
                    familyTreeView.Nodes.Add(Helper.BuildTree(profilesTable, -1));
                    if (!String.IsNullOrEmpty(Request.QueryString["ida"]))
                    {
                        addTree.Visible = true;
                        addTree.Attributes.Add("onclick", "AddRelation(" + treeId + ",'" + Request.QueryString["name"] + "');");
                    }
                }
            }
        }
    }
}